﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StudentInfo
{
    public partial class StudentInfoUIForm : Form
    {
        public StudentInfoUIForm()
        {
            InitializeComponent();
        }

        protected int TextBoxCount = 5;

        public enum TextBoxIndices
        {
            FIRSTNAME,
            LASTNAME,
            ID,
            CLASS,
            GRADE
        }

        public string[] GetTextBoxValues()
        {
            string[] values = new string[TextBoxCount];

            values[(int) TextBoxIndices.FIRSTNAME] = firstNameTextBox.Text;
            values[(int) TextBoxIndices.LASTNAME] = lastNameTextBox.Text;
            values[(int) TextBoxIndices.ID] = idTextBox.Text;
            values[(int) TextBoxIndices.CLASS] = classTextBox.Text;
            values[(int) TextBoxIndices.GRADE] = gradeTextBox.Text;

            return values;
        }

        public void SetTextBoxValues(string[] values)
        {
            if (values.Length == TextBoxCount)
            {
                firstNameTextBox.Text = values[(int) TextBoxIndices.FIRSTNAME];
                lastNameTextBox.Text = values[(int) TextBoxIndices.LASTNAME];
                idTextBox.Text = values[(int) TextBoxIndices.ID];
                classTextBox.Text = values[(int) TextBoxIndices.CLASS];
                gradeTextBox.Text = values[(int) TextBoxIndices.GRADE];
            }
        }

        public void ClearTextBoxes()
        {
            foreach (Control control in Controls)
            {
                if (control is TextBox)
                    ((TextBox) control).Clear();
            }
        }

        public void TextBoxesEnabled(bool enabledStatus)
        {
            foreach (Control control in Controls)
            {
                if (control is TextBox)
                    ((TextBox)control).Enabled = enabledStatus;
            }
        }
    }
}
